var app = new Vue({
    el: '#product',
    data() {
        return {
            msg: 'product',
            //产品总条数
            total: 100,
            productList: [{
                    index: 1,
                    name: '产品1',
                    backgroundDiv: {
                        backgroundImage: 'url(../img/pro1.png)'
                    }
                },
                {
                    index: 2,
                    name: '产品2',
                    backgroundDiv: {
                        backgroundImage: 'url(../img/pro2.gif)'
                    }
                },
                {
                    index: 3,
                    name: '产品3',
                    backgroundDiv: {
                        backgroundImage: 'url(../img/pro3.png) '
                    }
                },
                {
                    index: 4,
                    name: '产品4',
                    backgroundDiv: {
                        backgroundImage: 'url(../img/pro4.png)'
                    }
                },
                {
                    index: 5,
                    name: '产品5',
                    backgroundDiv: {
                        backgroundImage: 'url(../img/pro5.png) '
                    }
                },
                {
                    index: 6,
                    name: '产品6',
                    backgroundDiv: {
                        backgroundImage: 'url(../img/pro6.png)'
                    }
                }
            ],
            //每页数据条数
            params: {
                pageNo: 1,
                pageSize: 6,
                record: {}
            },
            index: 1,
            bannerImage: ''
        }
    },
    created() {
        this.getProductList()
    },
    methods: {
        getProductList() {
            this.getHeaderList();
            getProductList(this.params).then(res => {
                console.log(res)
                this.productList = res.data.data.list;
                console.log(this.productList);
            })


        },
        getHeaderList() {
            var storage = window.sessionStorage;

            var c = storage.getItem("headerList");

            if (!c) {
                axios.get('system/service/viewMenu/findAll')
                    .then(res => {
                        this.headerList1 = res.data.data;
                        this.bannerImage = this.headerList1[this.index].bgImg
                        storage.setItem("headerList", JSON.stringify(this.headerList1));
                    })
                    .catch(err => {
                        console.error(err);
                    })
            } else {
                this.headerList1 = JSON.parse(c);
                this.bannerImage = this.headerList1[this.index].bgImg
            }
        }
    }
})